home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 045a / btp15.zip / CREATE2.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-08  |  2KB  |  61 lines

  1. PROGRAM Create2;              { (C) 1991 John C. Leon   last updated 11/7/91 }
  2.  
  3. {
  4. Creates an empty Btrieve file of record length 30 with 2 keys.  This empty
  5. file is used in EXAMPLE1.PAS, and should be named EXAMPLE (no extension).
  6. }
  7.  
  8. {$IFDEF production} {$D-,R-,L-,S-} {$ENDIF}
  9.  
  10. USES
  11.    BTP;
  12.  
  13. VAR
  14.    Counter,
  15.    Counter1   : integer;
  16.    MyFileSpec : PFileSpec;
  17.    MyFileName : string;
  18.    MyAltColSeq: PAltColSeq;
  19.  
  20. BEGIN
  21.   MyFileSpec := new(PFileSpec);
  22.   with MyFileSpec^ do
  23.     begin
  24.       {Create a fixed length, standard Btrieve file, with no pre-allocation, }
  25.       {using UPPER.ALT as collating sequence for both keys.                  }
  26.       RecLen   :=   30;   FileFlags := 0;
  27.       PageSize :=  512;   PreAlloc  := 0;
  28.       NumKeys  :=    2;
  29.       fillchar(KeyArray, sizeof(KeyArray), 0);       {This line is MANDATORY!}
  30.       {Key #0}
  31.       with KeyArray[0] do
  32.          begin
  33.          KeyPos := 11; KeyLen := 20;
  34.          {recommend ALWAYS using ExtType in KeyFlags assignment}
  35.          KeyFlags := Duplicates + Modifiable + AltCol + ExtType;
  36.          ExtKeyType:= BString; {always assign a value to this element}
  37.          end;
  38.       {Key #1}
  39.       with KeyArray[1] do
  40.          begin
  41.          KeyPos :=  1; KeyLen := 10;
  42.          KeyFlags := Duplicates + Modifiable + AltCol + ExtType;
  43.          ExtKeyType := BString;
  44.          end;
  45.     end; {with MyFileSpec^ do}
  46.  
  47.   write('Enter name of file to create: ');
  48.   readln(MyFileName);
  49.   BStatus := CreateFile(MyFileName, MyFileSpec, 'Upper.Alt');
  50.   dispose(MyFileSpec);
  51.   if BStatus <> 0 then
  52.     writeln('Error creating file.  Status = ', BStatus)
  53.     else
  54.     begin
  55.     for Counter := 1 to length(MyFileName) do
  56.        MyFileName[Counter] := upcase(MyFileName[Counter]);
  57.     writeln('File ', MyFileName, ' created successfully.');
  58.     end;
  59.  
  60. END.
  61.